var pagingObj = null;
function searchBanner(page){
	var search_banner_keyword = $('#search_banner_keyword').val();
	var tableName = $("#hidTable").val();
	var urlLink = document.getElementById("urldefault").value+ 'manageBanner/searchBanner';
	var total = 0;
	
	if(pagingObj != null && pagingObj.page == "1"){
		total = pagingObj.total;
	}
	callBlockUI();
	$.post(urlLink, 
			{	
				page : page, 				
				search_name: $("#search_name").val(),
				search_type: $("#search_type").val(),
				total: total
			},
			function (data) {
				data = eval('('+data+')'); 
				$.unblockUI();
				buildAminBannerList(data);
				pagingObj = data.pPaging;
	});
	
}
function buildAminBannerList(result){
	
	if(result["bannerList"].length == 0){
		$('#searchbannerResult').html("");
		$("#divPagingResult").html("0 item found.");
		return;
	}
	
	
	var text = ''; 
	text += '<table class="displayTable">';
	text += '<tbody>';
	text += '<tr>';
	text += '<th align="left" width="5px">ID</th>';
	text += '<th align="left" width="170px">Name</th>';
	text += '<th align="left" width="50px">Status</th>';
	text += '<th align="left" width="30px">Edit</th>';
	text += '</tr>';
	
	var length = result.bannerList.length;
	if(length > 0){
		for(var i = 0; i<length; i++){
			var banner = result.bannerList[i];
			text += '<tr class="evenRow" align = "center">';
			text += '<td>' + banner.id + '</td>';
			text += '<td>' + banner.name + '</td>';
			
		    text += '<td style = "text-align : center;">'
			text += banner.status;
			text += '</td>';
			text += '<td>';
			text += '<input type="image" title="View Detail" alt="View Detail" src="/action_edit.gif' +'" onclick="viewbannerDetail('+banner.id+')">';
			text += '</td>';
		}
	}
	
	text += '</tbody>';
	text += '</table>';
	$('#searchBannerResult').html(text);
	buildSearchPaging(result, 'searchBanner');
}

function clearValueInSearchBanner(){
	clearSearchZone('searchBannerZone');
	$('#search_status').val(1);
}


